﻿
<!DOCTYPE html>
<html>
<head>
<title>the5fire.net-backbone.js-Hello World</title>
</head>
<body>
	<button id="check">报到</button>
	<ul id="world-list">

	</ul>
</body>
<script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
<script src="http://www.css88.com/doc/underscore/underscore-min.js"></script>
<script src="http://www.css88.com/doc/underscore/backbone-min.js"></script>
<script>
Book = Backbone.Model.extend({  
	  
default : {  
  
title:'default'  
  
},  
  
initialize: function(){  
  
//alert('Hey, you create me!');  
  
}  
  
});  
  
BookShelf = Backbone.Collection.extend({  
  
model : Book  
  
});  
  
var book1 = new Book({title : 'book1'});  
  
var book2 = new Book({title : 'book2'});  
  
var book3 = new Book({title : 'book3'});  
  
//var bookShelf = new BookShelf([book1, book2, book3]); //注意这里面是数组,或者使用add  
  
var bookShelf = new BookShelf;  
  
bookShelf.add(book1);  
  
bookShelf.add(book2);  
  
bookShelf.add(book3);  
  
bookShelf.remove(book3);  
  
  
  
//基于underscore这个js库，还可以使用each的方法获取collection中的数据  
  
bookShelf.each(function(book){  
  
alert(book.get('title'));  
  
});  
</script>
</html>